<%
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", -1); //prevents caching at the proxy server
%>
<%@page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*,java.text.*"%>
<%@ include file="Connections/conDB.jsp" %>
<%
String no_certificado = request.getParameter("id");
String rsNo_certificado = "";
String rsFecha_exped = "";
String rsVolumen = "";
String rsUnidad_metrica = "";
String rsFecha_inicio = "";
String rsFecha_fin = "";
String rsTipo_grano = "";
NumberFormat nf  = new DecimalFormat("#,###.###");


Driver DriverRs = (Driver)Class.forName(MM_conDB_DRIVER).newInstance();
Connection ConnRs = DriverManager.getConnection(MM_conDB_STRING,MM_conDB_USERNAME,MM_conDB_PASSWORD);
String query = "SELECT "+
				"no_certificado, CONVERT(VARCHAR,fecha_exped,103) AS fecha_exped2, volumen, "+
				"unidad_metrica, CONVERT(VARCHAR,fecha_inicio,103) AS fecha_inicio2, CONVERT(VARCHAR,fecha_fin,103) AS fecha_fin2, tipo_grano "+
				"FROM cupo WHERE no_certificado = '"+no_certificado+"'";
PreparedStatement StatementRs = ConnRs.prepareStatement(query);;
ResultSet Rsquery = StatementRs.executeQuery();;
boolean Rsquery_hasData = Rsquery.next();
Object Rsquery_data;

if (Rsquery_hasData) {
	rsNo_certificado = Rsquery.getString("no_certificado");
	rsFecha_exped = Rsquery.getString("fecha_exped2");
	rsVolumen = Rsquery.getString("volumen");
	rsUnidad_metrica = Rsquery.getString("unidad_metrica");
	rsFecha_inicio = Rsquery.getString("fecha_inicio2");
	rsFecha_fin = Rsquery.getString("fecha_fin2");
	rsTipo_grano = Rsquery.getString("tipo_grano");
}

query = "SELECT * FROM tipo_grano ORDER BY tipo_grano ASC, color ASC";
StatementRs = ConnRs.prepareStatement(query);
ResultSet Rsquery2 = StatementRs.executeQuery();
boolean Rsquery2_hasData = Rsquery2.next();
Object Rsquery2_data;

%>
<html>
<head>
<title>CIMA v2 - Modificar Cupo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="miestilo.css" type="text/css">
<SCRIPT LANGUAGE="JavaScript" SRC="js/AnchorPosition.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="js/PopupWindow.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="js/date.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="js/CalendarPopup.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
	var cal1 = new CalendarPopup();
</SCRIPT>

</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
<br>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td align="center" class="titulos" height="22">Modificar Cupo</td>
    </tr>
  </table>
  <br>
<form name="form1">
    <table width="300" border="0" cellspacing="0" cellpadding="0">
      <tr> 
        <td align="right" class="etiqueta" width="112">No. de Certificado</td>
        <td width="15">&nbsp;</td>
        <td> 
          <input type="text" name="textfield" class="textfields" maxlength="50" size="19" value="<%=rsNo_certificado%>"></td>
      </tr>
      <tr> 
        <td align="right" class="etiqueta">Fecha de Expedici&oacute;n</td>
        <td></td>
        <td> 
          <input type="text" name="textfield2" class="textfields" size="19" maxlength="50" onClick="blur()" value="<%=rsFecha_exped%>">
          <img src="images/calendar.jpg" class="cursor" name="Button1" onClick="cal1.select(document.form1.textfield2,'Button1','dd/MM/yyyy'); return false;"></td>
      </tr>
      <tr> 
        <td align="right" class="etiqueta">Vol&uacute;men</td>
        <td>&nbsp;</td>
        <td> 
          <input type="text" name="textfield3" class="textfields" maxlength="50" size="19" value="<%=rsVolumen%>">
        </td>
      </tr>
      <tr> 
        <td align="right" class="etiqueta">Unidad M&eacute;trica</td>
        <td>&nbsp;</td>
        <td>
          <input type="hidden" name="textfield4" class="textfields" maxlength="50" size="19" value="Tonelada" onClick="blur()">
		  Tonelada
        </td>
      </tr>
      <tr> 
        <td align="right" class="etiqueta">Fecha de Inicio</td>
        <td>&nbsp;</td>
        <td> 
          <input type="text" name="textfield5" class="textfields" maxlength="50" size="19" onClick="blur()" value="<%=rsFecha_inicio%>">
          <img src="images/calendar.jpg" width="24" height="21" class="cursor" name="Button2" onClick="cal1.select(document.form1.textfield5,'Button2','dd/MM/yyyy'); return false;"> 
        </td>
      </tr>
      <tr> 
        <td align="right" class="etiqueta">Fecha de Vencimiento</td>
        <td>&nbsp;</td>
        <td> 
          <input type="text" name="textfield6" class="textfields" maxlength="50" size="19" onClick="blur()" value="<%=rsFecha_fin%>">
		  <img src="images/calendar.jpg" width="24" height="21" class="cursor" name="Button3" onClick="cal1.select(document.form1.textfield6,'Button3','dd/MM/yyyy'); return false;">
        </td>
      </tr>
      <tr> 
        <td align="right" class="etiqueta">Tipo de Grano</td>
        <td>&nbsp;</td>
        <td>
          <select name="selTipo_grano" size="1" class="textfields">
            <option value="ninguno">- - Tipo - -</option>
			<% while (Rsquery2_hasData) { %>
				<option value="<%=Rsquery2.getObject("id")%>"><%=Rsquery2.getObject("tipo_grano")+" "+Rsquery2.getObject("color")%></option>
			<% Rsquery2_hasData = Rsquery2.next();
			  }
			%>
          </select>
		<script>
			for (x=0;x<document.form1.selTipo_grano.length;x++) {
				if (document.form1.selTipo_grano[x].value==<%=rsTipo_grano%>) {
					document.form1.selTipo_grano.selectedIndex = x;
					break;
				}
			}
		</script>
        </td>
      </tr>

      <tr> 
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr> 
        <td colspan="3" align="center"> 
          <input type="submit" name="Submit" value="Guardar" class="boton" onClick="window.close()">
          &nbsp;
          <input type="button" name="Submit3" value="Cerrar" class="boton" onClick="window.close()">
        </td>
      </tr>
    </table>
  </form>
</center>

</body>
<HEAD>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</HEAD>
</html>
<%
Rsquery.close();
Rsquery2.close();
StatementRs.close();
ConnRs.close();
%>